package cn.ainit.yz.comparsion;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.ainit.common.ReturnObject;
import cn.ainit.yz.comparsion.entity.YzComparison;

@Controller
@RequestMapping("/yzComCon")  
public class YzComparsionController {
	private YzComparsonService yzComparsonService;
	@Resource
	public void setYzComparsonService(YzComparsonService yzComparsonService) {
		this.yzComparsonService = yzComparsonService;
	}
	
	@RequestMapping("/saOrUpdYzComp")
	@ResponseBody
	public ReturnObject saveOrUpdComp(YzComparison yzComparison,int panduan,HttpServletRequest request) throws Exception{
		ReturnObject returnObject = new ReturnObject();
		try {
			boolean flag = false;
			if (panduan == 0) {
				flag = yzComparsonService.saveYzComp(yzComparison);
				if (flag) {
					returnObject.setMsg("success");
					returnObject.setInfo(yzComparison.getCodeid());
				}else{
					returnObject.setMsg("fail");
				}
			}else{
				flag = yzComparsonService.updCompSave(yzComparison);
				if (flag) {
					returnObject.setMsg("upsuccess");
				}else {
					returnObject.setMsg("fail");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return returnObject;
	}
}
